package cn.lhx.blog.dao;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.taglibs.bsf.scriptlet;

import cn.lhx.blog.pojo.ArticleOrigin;

public class DaoArticOrg {
	private static int ORIGINAL=1;//原创
	private static int REFERENCE=2;//转载
	private static int TRANCELATE=3;//翻译
	private static int FREEWRITE=4;//随笔
	private static int OTHER=5;
	
	private static Map<Integer, ArticleOrigin> orgMap=new HashMap<Integer, ArticleOrigin>();
	static{
		orgMap.put(ORIGINAL, new ArticleOrigin(ORIGINAL,"原创"));
		orgMap.put(REFERENCE, new ArticleOrigin(REFERENCE,"转载"));
		orgMap.put(TRANCELATE, new ArticleOrigin(TRANCELATE,"翻译"));
		orgMap.put(FREEWRITE, new ArticleOrigin(FREEWRITE,"随笔"));
		orgMap.put(OTHER,new ArticleOrigin(OTHER,"其他"));
	}
	
	/**
	 * 根据Id获得来源
	 * @param id
	 * @return
	 */
	public ArticleOrigin getOrgById(int id){
		return orgMap.get(id);
	}
	/**
	 * 获得所有文章来源
	 * @return 返回一个迭代器
	 */
	public Iterator<ArticleOrigin> getAllOrg(){
		return orgMap.values().iterator();
	}

}
